{extend name="index/iframe" /}

{block name="content"}
<div style="padding: 10px;">
    <table id="tableBox" lay-filter="tableBox"></table>
</div>
{/block}

{block name="css"}{/block}

{block name="js"}
<script>
    layui.use(['form', 'table'], function(){
        var $ = layui.$
            ,table = layui.table
            ,load = layer.load()
            ,form = layui.form;

        //表格初始化
        table.render({
            elem: '#tableBox'
            ,url: '{:url("InfoRole/pay")}'
            ,where: {
                "date": "{$Think.get.date}"
                ,"channel_id": "{$Think.get.channel_id}"
                ,"game_id": "{$Think.get.game_id}"
                ,"my_user_id": "{$Think.get.my_user_id}"
                ,"server_id": "{$Think.get.server_id}"
                ,"role_id": "{$Think.get.role_id}"
                ,"sort": "{$Think.get.sort}"
            }
            ,page: true
            ,limit: 13
            ,limits: [13,40,60]
            ,loading: true
            ,id: 'tableId'
            ,done: function (res, curr, count) {
                layer.close(load);
            }
            ,cols: [[
                {field:'pay_time', title: '充值时间'}
                ,{field:'channel_id', title: '渠道名称'}
                ,{field:'game_id', title: '游戏名称'}
                ,{field:'server_id', title: '区服名称'}
                ,{field:'role_id', title: '角色名称'}
                ,{field:'vip', title: 'VIP'}
                ,{field:'level', title: '等级'}
                ,{field:'product_name', title: '产品名称'}
                ,{field:'total_price', title: '充值金额'}
            ]]
        });

        form.on('submit(submitBtn)', function(data){
            var load = layer.load();
            $.post('{:url("AuditSdkInfo/add")}',data.field, function(json){
                layer.close(load);
                if(json.code==0){
                    layer.msg(json.msg, {icon: 1, time: 1000})
                    setTimeout(function(){
                        window.location.reload();
                    }, 1000);
                }else{
                    layer.msg(json.msg, {icon: 0, time: 1000});
                }
            }, 'JSON').error(function(){
                layer.close(load);
                layer.msg('连接超时，请联系后台管理员', {icon: 2, time:3000});
            });
            return false;
        });

        table.on('tool(tableBox)', function(obj) {
            var data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('确定要删除吗？', {offset: '250px'}, function(index){
                    var load = layer.load();
                    $.post('{:url("AuditSdkInfo/del")}',{id: data.id}, function(json){
                        layer.close(load);
                        if(json.code==0){
                            obj.del();
                            layer.msg(json.msg, {icon: 1, time:1000})
                        }else{
                            layer.msg(json.msg, {icon: 0, time:1000});
                        }
                    }, 'JSON').error(function(){
                        layer.close(load);
                        layer.msg('连接超时，请联系后台管理员', {icon: 2, time:3000});
                    });
                });
            }
        });

    });
</script>
{/block}